package interfaz;

import java.util.ArrayList;
import java.util.List;

import org.uqbar.arena.actions.MessageSend;
import org.uqbar.arena.layout.ColumnLayout;
import org.uqbar.arena.widgets.Button;
import org.uqbar.arena.widgets.Label;
import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.widgets.Selector;
import org.uqbar.arena.widgets.TextBox;
import org.uqbar.arena.windows.SimpleWindow;
import org.uqbar.arena.windows.WindowOwner;

import adapter.MesaAdapter;
import apuesta.Apuesta;
import apuesta.Fila;

public class ApuestaFilaWindow extends ApuestaAbstractWindow {
	


	public ApuestaFilaWindow(WindowOwner parent, MesaAdapter model) {
		super(parent, model);
	
	}
	
	private List<Integer> initialize() {
		List<Integer> options = new ArrayList<Integer>();
		for (int i = 1; i <= 12; i++) {
			options.add(i);
		}
		return options;
	}
	protected void addActions(Panel actionsPanel) {
	
		
	}

	protected void createMainTemplate(Panel mainPanel) {
		
		mainPanel.setLayout(new ColumnLayout(2));

		this.setTitle("Apuesta a una fila");

		Label apostar = new Label(mainPanel);
		apostar.setText("Apostar a" + "\n");

		List<Integer> options = this.initialize();
		Selector numeros = new Selector(mainPanel);
		numeros.setContents(options);
		numeros.bindValueToProperty(MesaAdapter.NUMEROAPOSTADO);

		Label fichas = new Label(mainPanel);
		fichas.setText("fichas" + "\n");

		TextBox cantidad = new TextBox(mainPanel);
		cantidad.bindValueToProperty(MesaAdapter.CANTIDADPARAAPOSTAR);

		
		Button aceptar = new Button(mainPanel);	
		aceptar.setCaption("Aceptar");
		aceptar.disableOnError(); //$#"$%&
		aceptar.onClick(new MessageSend(this,ACCEPT));
			
		Button Cancelar = new Button(mainPanel);
		Cancelar.setCaption("Cancelar");
		Cancelar.onClick(new MessageSend(this,CANCEL));
		
		
	}

	@Override
	protected void createFormPanel(Panel mainPanel) {
		
		
	}

	@Override
	protected void executeTask() {
		this.getModel().setTipoApuesta(new Fila());
		this.getModel().apostar();
		
	}


}
